/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nuanshui.heatedloan.search.facade.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.google.common.collect.Lists;

/**
 *
 */
public class ElasticSearchRequest implements Serializable{
    
	/**
	 * 
	 */
	private static final long serialVersionUID = 1563453389319914906L;
	/**
	 * 排序的常量
	 */
	public final static int  ORDER_DIRECTION_ASC = 1;//升序
	public final static int ORDER_DIRECTION_DESC = -1;//降序
    private String index; //索引
    private String type; //类型
    private String id; //id
    private int  size = 10;//每页的个数
    private int  page = 1;//第几页
    
    private List<SearchParams> searchParams = Lists.newArrayList();
    
    //查询需要的条件
    private HashMap<String,String> params = new HashMap<String, String>();
    //需要高亮的 字段
    private List<String> highLineFileds = new ArrayList<String>();
    //要排序的字段
    private HashMap<String,Integer> sortFileds = new HashMap<String, Integer>();
    
    private FieldValueFactor fieldValueFactor;
    
    public FieldValueFactor getFieldValueFactor() {
		return fieldValueFactor;
	}

	public void setFieldValueFactor(FieldValueFactor fieldValueFactor) {
		this.fieldValueFactor = fieldValueFactor;
	}

	public List<SearchParams> getSearchParams() {
		return searchParams;
	}

	public void setSearchParams(List<SearchParams> searchParams) {
		this.searchParams = searchParams;
	}

	public void addSortFiled(String filed,Integer sortType) {
       sortFileds.put(filed,sortType);	
    }
    
    public void addParam(String key,String value) {  	
    	params.put(key, value);	
    }
    
    public void addHighLineFiled(String  filed) {
    	highLineFileds.add(filed);
    	
    }
    
    

	public HashMap<String, Integer> getSortFileds() {
		return sortFileds;
	}

	public void setSortFileds(HashMap<String, Integer> sortFileds) {
		this.sortFileds = sortFileds;
	}

	public int getOffset() {
    	return page*size;
    }
    
    public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public HashMap<String, String> getParams() {
		return params;
	}

	public void setParams(HashMap<String, String> params) {
		if(params == null) return;
		this.params = params;
	}

	public List<String> getHighLineFileds() {
		return highLineFileds;
	}

	public void setHighLineFileds(List<String> highLineFileds) {
		if(highLineFileds == null) return;
		this.highLineFileds = highLineFileds;
	}

	public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    
    
}
